import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
import {MessagePage} from "../pages/message/message";

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav:Nav;

  rootPage:any = HomePage;

  pages:Array<{title: string, component: any}>;
  socialPages: any;
  settingPages: any;
  setPage: any;
  icon: string;

  constructor(public platform:Platform, public statusBar:StatusBar, public splashScreen:SplashScreen) {
    this.initializeApp();
    this.icon = '';
    // used for an example of ngFor and navigation
    this.pages = [
      // {title: 'Home', component: HomePage},
      // {title: 'List', component: ListPage},
      {title: '我的消息', component: MessagePage},
      {title: '会员中心', component: ListPage},
      {title: '商城', component: ListPage},
      {title: '游戏推荐Beta', component: ListPage},
      {title: '在线听歌免流量', component: ListPage}
    ];
    this.socialPages = [
      {title: '我的好友', component: HomePage},
      {title: '附近的人', component: ListPage}
    ];
    this.settingPages = [
      {title: '个性换肤', component: HomePage},
      {title: '听歌识曲', component: HomePage},
      {title: '定时停止播放', component: HomePage},
      {title: '扫一扫', component: HomePage},
      {title: '音乐闹钟', component: HomePage},
      {title: '驾驶模式', component: HomePage},
      {title: '音乐云盘', component: HomePage},
      {title: '优惠券', component: HomePage}
    ];

    this.setPage = {component: HomePage};

  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      this.statusBar.styleDefault();
      this.splashScreen.hide();
    });
  }

  openPage(page) {
    console.log(page);
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    //this.nav.setRoot(page.component);
    this.nav.push(page.component);
  }
}
